package org.okcjug.december.set;

import java.math.BigDecimal;
import java.util.TreeSet;
import junit.framework.TestCase;

import org.okcjug.december.set.objects.XmasTree;

public class MyTreeSet extends TestCase
{
	private TreeSet<XmasTree> xmasTreeSet;
	
	@Override
	protected void setUp() throws Exception
	{
		super.setUp();
	}
	
	private void setUpXmasTreeSet()
	{
		xmasTreeSet = new TreeSet<XmasTree>();
		
		xmasTreeSet.add(getFurTreeA());
		xmasTreeSet.add(getFurTreeB());
		xmasTreeSet.add(getPlasticTreeA());
		xmasTreeSet.add(getPlasticTreeB());
		
		displayXmasTreeSet();
	}

	public void _testXmasTreeSet_first_last()
	{
		setUpXmasTreeSet();
		
		System.err.println("first: " + xmasTreeSet.first().toString() + "\n");
		
		System.err.println("last:  " + xmasTreeSet.last().toString() + "\n");
	}

	public void _testXmasTreeSet_poll()
	{
		setUpXmasTreeSet();
		
		System.err.println("pollFirst: " + xmasTreeSet.pollFirst() + "\n");
		
		displayXmasTreeSet();
		
		System.err.println("pollLast: " + xmasTreeSet.pollLast() + "\n");
		
		displayXmasTreeSet();
	}

	public void _testTreeSet_floor()
	{
		TreeSet<String> mySet = new TreeSet<String>();
		mySet.add("E");
		mySet.add("D");
		
		mySet.add("B");
		mySet.add("A");

		System.err.println(mySet + "\n");
		
		System.err.println("floor C  : " + mySet.floor("C"));
		System.err.println("lower C:   " + mySet.lower("C") + "\n");

		System.err.println("ceiling C: " + mySet.ceiling("C"));
		System.err.println("higher C:  " + mySet.higher("C"));
	}
	



	
// -----------------------------------------------------------
	private void displayXmasTreeSet()
	{
		for (XmasTree xmasTree : xmasTreeSet)
		{
			System.err.println(xmasTree);
		}
		System.err.println("");
	}
	
	private XmasTree getFurTreeA()
	{
		XmasTree tree = new XmasTree();
		tree.setType("Fur");
		tree.setHeightInInches(72);
		tree.setBaseIncluded(false);
		tree.setFrocked(false);
		tree.setLightsIncluded(false);
		tree.setPrice(new BigDecimal("78.56"));
		return tree;
	}
	private XmasTree getFurTreeB()
	{
		XmasTree tree = new XmasTree();
		tree.setType("Fur");
		tree.setHeightInInches(60);
		tree.setBaseIncluded(false);
		tree.setFrocked(false);
		tree.setLightsIncluded(false);
		tree.setPrice(new BigDecimal("65.78"));
		return tree;
	}
	private XmasTree getPlasticTreeA()
	{
		XmasTree tree = new XmasTree();
		tree.setType("Plastic");
		tree.setHeightInInches(48);
		tree.setBaseIncluded(true);
		tree.setFrocked(false);
		tree.setLightsIncluded(true);
		tree.setPrice(new BigDecimal("55.66"));
		return tree;
	}
	private XmasTree getPlasticTreeB()
	{
		XmasTree tree = new XmasTree();
		tree.setType("Plastic");
		tree.setHeightInInches(32);
		tree.setBaseIncluded(true);
		tree.setFrocked(true);
		tree.setLightsIncluded(true);
		tree.setPrice(new BigDecimal("45.32"));
		return tree;
	}
	
}
